package com.stone.serverless.web;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

/**
 * @Description: TODO
 * @Author: MECHREVO
 * @Date: 2022/1/25 16:29
 * @Version: 1.0.0
 */
@Component
public class HandlerMappingPostProcessor implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {

        if (bean instanceof RequestMappingHandlerMapping) {
            return new ClassLoaderRequestMappingInfoHandlerMapping((RequestMappingHandlerMapping) bean);
        }

        return bean;
    }
}
